<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="product-item">
    <image
      class="product-item-img"
      :src="info.pic_url"
      mode="aspectFill"
      lazy-load
      :style="{
        height:
          info.order_type === 2
            ? '110rpx'
            : info.order_type === 3
            ? '104rpx'
            : '140rpx',
      }"
    />
    <view class="product-item-content">
      <view class="product-item-name">{{ info.product_name }}</view>
      <view style="display: flex; align-items: center; width: 100%">
        <view class="product-item-price">
          <view class="product-item-price2">¥</view>{{ info.min_price }}
          <view class="product-item-price3">起</view>
        </view>
        <view class="product-item-num">{{ info.sold_count_str }}</view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.product-item {
  display: flex;
  padding: 20rpx;
  border-radius: 20rpx;
  background-color: #ffffff;

  .product-item-img {
    flex-shrink: 0;
    width: 148rpx;
    border-radius: 20rpx;
  }

  .product-item-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
    min-width: 0;
    margin-left: 20rpx;
  }

  .product-item-name {
    width: 100%;
    margin-bottom: auto;
    font-size: 28rpx;
    color: #333333;
    line-height: 42rpx;
    font-weight: bold;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .product-item-price {
    display: flex;
    align-items: flex-end;
    font-size: 36rpx;
    color: #fa6400;
    line-height: 50rpx;
    font-weight: bold;
  }

  .product-item-price2 {
    margin-right: 4rpx;
    font-size: 22rpx;
    line-height: 44rpx;
  }

  .product-item-price3 {
    margin-left: 4rpx;
    font-size: 24rpx;
    color: #666666;
    line-height: 46rpx;
    font-weight: 400;
  }

  .product-item-num {
    margin-left: 20rpx;
    font-size: 24rpx;
    color: #999999;
    line-height: 34rpx;
  }
}
</style>